package com.buildings.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.buildings.R;
import com.buildings.activity.table.CraterActivity;
import com.buildings.activity.table.DrillHoleActivity;
import com.buildings.activity.table.FaultSvyPointActivity;
import com.buildings.activity.table.GeoGeomorphySvyPointActivity;
import com.buildings.activity.table.GeochemicalSvyLineActivity;
import com.buildings.activity.table.GeochemicalSvyPointActivity;
import com.buildings.activity.table.GeologicalSvyLineActivity;
import com.buildings.activity.table.GeologicalSvyPlanningLineActivity;
import com.buildings.activity.table.GeologicalSvyPlanningPtActivity;
import com.buildings.activity.table.GeologicalSvyPointActivity;
import com.buildings.activity.table.GeomorStationActivity;
import com.buildings.activity.table.GeomorphySvyLineActivity;
import com.buildings.activity.table.GeomorphySvyPointActivity;
import com.buildings.activity.table.GeomorphySvyReProfActivity;
import com.buildings.activity.table.GeomorphySvyRegionActivity;
import com.buildings.activity.table.GeomorphySvySamplePointActivity;
import com.buildings.activity.table.GeophySvyLineActivity;
import com.buildings.activity.table.GeophySvyPointActivity;
import com.buildings.activity.table.LavaActivity;
import com.buildings.activity.table.SamplePointActivity;
import com.buildings.activity.table.StratigraphySvyPointActivity;
import com.buildings.activity.table.TanCaodianActivity;
import com.buildings.activity.table.VolcanicSamplePointActivity;
import com.buildings.activity.table.VolcanicSvyPointActivity;
import com.buildings.adapter.LocalAdapter;
import com.buildings.adapter.TableListAdapter;
import com.buildings.adapter.TaskListNewAdapter;
import com.buildings.api.Api;
import com.buildings.base.BaseActivity;
import com.buildings.base.BaseApplication;
import com.buildings.bean.CreaterDbEntity;
import com.buildings.bean.DrillHoleDbEntity;
import com.buildings.bean.FaultSvyPointDbEntity;
import com.buildings.bean.GeoGeomorphySvyPointDbEntity;
import com.buildings.bean.GeochemicalSvyLineDbEntity;
import com.buildings.bean.GeochemicalSvyPointDbEntity;
import com.buildings.bean.GeologicalSvyLineDbEntitiy;
import com.buildings.bean.GeologicalSvyPlanningLineDbEntity;
import com.buildings.bean.GeologicalSvyPlanningPtDbEntity;
import com.buildings.bean.GeologicalSvyPointDbEntity;
import com.buildings.bean.GeomorStationDbEntity;
import com.buildings.bean.GeomorphySvyLineDbEntity;
import com.buildings.bean.GeomorphySvyPointDbEntity;
import com.buildings.bean.GeomorphySvyReProfDbEntity;
import com.buildings.bean.GeomorphySvyRegionDbEntity;
import com.buildings.bean.GeomorphySvySamplePointDbEntity;
import com.buildings.bean.GeophySvyLineDbEntity;
import com.buildings.bean.GeophySvyPointDbEntity;
import com.buildings.bean.LavaDbEntity;
import com.buildings.bean.LocalBean;
import com.buildings.bean.ProjectBean;
import com.buildings.bean.ProjectListBean;
import com.buildings.bean.SamplePointDbEntity;
import com.buildings.bean.SeeTableBean;
import com.buildings.bean.StratigraphySvyPointDbEntity;
import com.buildings.bean.TableBean;
import com.buildings.bean.TanCaodianDbEntity;
import com.buildings.bean.VolcanicSamplePointDbEntity;
import com.buildings.bean.VolcanicSvyPointDbEntity;
import com.buildings.event.MessageEvent;
import com.buildings.http.BaseCallBack;
import com.buildings.http.JsonBuilder;
import com.buildings.http.MyHttpClient;
import com.buildings.util.CustomToast;
import com.buildings.util.SPUtil;
import com.buildings.view.FragmentDialog;
import com.buildings.view.SelectTypeFragmentDialog;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadmoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.zr.earthquate.db.greendao.DaoSession;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import okhttp3.Call;

public class SeeTableListActivity extends BaseActivity {
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.refreshLayout)
    SmartRefreshLayout refreshLayout;
    @BindView(R.id.refreshLayout1)
    SmartRefreshLayout refreshLayout1;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    @BindView(R.id.tv_right_text)
    TextView tvightText;
    @BindView(R.id.tv_table)
    TextView tvTable;
    @BindView(R.id.tv_type)
    TextView tvType;
    @BindView(R.id.tv_comit)
    TextView tvComit;
    @BindView(R.id.tv_save)
    TextView tvSave;
    @BindView(R.id.recycle_db)
    RecyclerView recycleDb;
    private int pageNum = 1;
    private int total;
    private String projectId;
    private String projectName;
    private String taskId;
    private String taskName;
    private List<TableBean> datas = new ArrayList<>();
    private List<LocalBean> lcalDatas = new ArrayList<>();
    private TableListAdapter mAdapter;
    private LocalAdapter localAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_see_table_list);
        EventBus.getDefault().register(this);
        ButterKnife.bind(this);
        init();
    }

    @Override
    protected void onResume() {
        super.onResume();
        http();
        getLocalData();
    }

    private void init() {
        tvTitle.setText("");
        tvightText.setText("新建表单");
        if (!getIntent().hasExtra("projectId")) {
            finish();
        }
        if (!getIntent().hasExtra("task")) {
            finish();
        }
        projectId = getIntent().getStringExtra("projectId");
        projectName = getIntent().getStringExtra("projectName");
        taskName = getIntent().getStringExtra("taskName");
        taskId = getIntent().getStringExtra("task");

        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.addItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.VERTICAL));
        mAdapter = new TableListAdapter(this, datas);
        recyclerView.setAdapter(mAdapter);

        mAdapter.setOnItemClickListener(new TableListAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                //查看表单详情
                jumpTableDetail(position, "");
            }

            @Override
            public void onTask(View view, int position) {

            }

            @Override
            public void onForm(View view, int position) {

            }
        });
        refreshLayout.setOnLoadmoreListener(new OnLoadmoreListener() {
            @Override
            public void onLoadmore(RefreshLayout refreshlayout) {
                if (datas.size() >= total) {
                    CustomToast.showToast(SeeTableListActivity.this, "没有更多的任务");
                    refreshlayout.finishLoadmore();
                } else {
                    //todo 网络请求
                    pageNum++;
                    http();
                }
            }
        });
        refreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                pageNum = 1;
                //todo 网络请求
                http();
            }
        });

        recycleDb.setLayoutManager(new LinearLayoutManager(this));
        recycleDb.addItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.VERTICAL));
        localAdapter = new LocalAdapter(this, lcalDatas);
        recycleDb.setAdapter(localAdapter);
        localAdapter.setOnItemClickListener(new LocalAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                jumpTableDetail(position, "1");
            }

            @Override
            public void onDelete(int position) {
                //根据ID删除本地数据库数据
                deletePosition(position);
                getLocalData();
            }
        });
        refreshLayout1.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                getLocalData();
            }
        });
    }


    private void jumpTableDetail(int position, String location) {
        Intent intent;
        switch (selectTableId) {
            case "1":
                intent = new Intent(this, GeologicalSvyPlanningLineActivity.class);
                break;
            case "2":
                intent = new Intent(this, GeologicalSvyPlanningPtActivity.class);
                break;
            case "3":
                intent = new Intent(this, FaultSvyPointActivity.class);
                break;
            case "4":
                intent = new Intent(this, GeoGeomorphySvyPointActivity.class);
                break;
            case "5":
                intent = new Intent(this, GeologicalSvyLineActivity.class);
                break;
            case "6":
                intent = new Intent(this, GeologicalSvyPointActivity.class);
                break;
            case "7":
                intent = new Intent(this, StratigraphySvyPointActivity.class);
                break;
            case "8":
                intent = new Intent(this, TanCaodianActivity.class);
                break;
            case "9":
                intent = new Intent(this, GeomorphySvyLineActivity.class);
                break;
            case "10":
                intent = new Intent(this, GeomorphySvyPointActivity.class);
                break;
            case "11":
                intent = new Intent(this, GeomorphySvyRegionActivity.class);
                break;
            case "12":
                intent = new Intent(this, GeomorphySvyReProfActivity.class);
                break;
            case "13":
                intent = new Intent(this, GeomorphySvySamplePointActivity.class);
                break;
            case "14":
                intent = new Intent(this, GeomorStationActivity.class);
                break;
            case "15":
                intent = new Intent(this, DrillHoleActivity.class);
                break;
            case "16":
                intent = new Intent(this, SamplePointActivity.class);
                break;
            case "17":
                //todo 没测试
                intent = new Intent(this, GeophySvyLineActivity.class);
                break;
            case "18":
                //todo 没测试
                intent = new Intent(this, GeophySvyPointActivity.class);
                break;
            case "19":
                //todo 没测试
                intent = new Intent(this, GeochemicalSvyLineActivity.class);
                break;
            case "20":
                intent = new Intent(this, GeochemicalSvyPointActivity.class);
                break;
            case "21":
                intent = new Intent(this, CraterActivity.class);
                break;
            case "22":
                intent = new Intent(this, LavaActivity.class);
                break;
            case "23":
                intent = new Intent(this, VolcanicSamplePointActivity.class);
                break;
            default:
                intent = new Intent(this, VolcanicSvyPointActivity.class);
                break;
        }
        if (!TextUtils.isEmpty(location)) {
            intent.putExtra("_id", lcalDatas.get(position).get_id());
            intent.putExtra("joninType", 1);
            intent.putExtra("type", selectTableId);
            //todo bug 是否在线模式 不能拿location 判断
            intent.putExtra("isOnLine", false);
        } else {
            intent.putExtra("uuid", datas.get(position).getUuid());
            intent.putExtra("joninType", 2);
            intent.putExtra("isOnLine", true);
        }
        intent.putExtra("taskId", taskId);
        intent.putExtra("projectId", projectId);
        intent.putExtra("projectName", projectName);
        intent.putExtra("taskName", taskName);
        startActivity(intent);
    }

    @OnClick({R.id.iv_back, R.id.tv_right_text, R.id.tv_table, R.id.tv_type, R.id.tv_comit, R.id.tv_save})
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.tv_right_text:
                Intent intent = new Intent(activity, MapTableActivity.class);
                intent.putExtra("projectId", projectId);
                intent.putExtra("projectName", projectName);
                intent.putExtra("taskName", taskName);
                intent.putExtra("taskId", taskId);
                startActivity(intent);
                break;
            case R.id.tv_table:
                SelectTypeFragmentDialog.newInstance(2, typeName).show(getSupportFragmentManager(), "");
                break;
            case R.id.tv_type:
                SelectTypeFragmentDialog.newInstance(1, typeName).show(getSupportFragmentManager(), "");
                break;
            case R.id.tv_comit:
                tvComit.setTextColor(getResources().getColor(R.color.blue_58));
                tvSave.setTextColor(getResources().getColor(R.color.bottom_bg));
                refreshLayout.setVisibility(View.VISIBLE);
                refreshLayout1.setVisibility(View.GONE);
                break;
            case R.id.tv_save:
                tvComit.setTextColor(getResources().getColor(R.color.bottom_bg));
                tvSave.setTextColor(getResources().getColor(R.color.blue_58));
                refreshLayout.setVisibility(View.GONE);
                refreshLayout1.setVisibility(View.VISIBLE);
                break;
        }
    }

    private String selectTableId = "2";
    private String typeName;

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void receiveMessage(MessageEvent json) {
        typeName = json.getType();
        tvType.setText(json.getType());
        tvTable.setText(json.getTableName());
        selectTableId = json.getTableId();
        http();
        getLocalData();
    }

    public void getLocalData() {
        switch (selectTableId) {
            case "1":
                lcalDatas.clear();
                List<GeologicalSvyPlanningLineDbEntity> students = BaseApplication.getInstance().getDaoSession().loadAll(GeologicalSvyPlanningLineDbEntity.class);
                refreshLayout1.finishRefresh();
                if (students.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < students.size(); i++) {
                    if (projectId.equals(students.get(i).getProjectId())
                            && taskId.equals(students.get(i).getTaskId())
                            && !TextUtils.isEmpty(students.get(i).getProjectId())
                            && !TextUtils.isEmpty(students.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(students.get(i).getId());
                        localBean.set_id(students.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "2":
                lcalDatas.clear();
                List<GeologicalSvyPlanningPtDbEntity> geologicalSvyPlanningPtDbEntities = BaseApplication.getInstance().getDaoSession().loadAll(GeologicalSvyPlanningPtDbEntity.class);
                refreshLayout1.finishRefresh();
                if (geologicalSvyPlanningPtDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geologicalSvyPlanningPtDbEntities.size(); i++) {
                    if (projectId.equals(geologicalSvyPlanningPtDbEntities.get(i).getProjectId())
                            && taskId.equals(geologicalSvyPlanningPtDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(geologicalSvyPlanningPtDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(geologicalSvyPlanningPtDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geologicalSvyPlanningPtDbEntities.get(i).getId());
                        localBean.set_id(geologicalSvyPlanningPtDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "3":
                lcalDatas.clear();
                List<FaultSvyPointDbEntity> faultSvyPointDbEntities = BaseApplication.getInstance().getDaoSession().loadAll(FaultSvyPointDbEntity.class);
                refreshLayout1.finishRefresh();
                if (faultSvyPointDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < faultSvyPointDbEntities.size(); i++) {
                    if (projectId.equals(faultSvyPointDbEntities.get(i).getProjectId())
                            && taskId.equals(faultSvyPointDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(faultSvyPointDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(faultSvyPointDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(faultSvyPointDbEntities.get(i).getId());
                        localBean.set_id(faultSvyPointDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "4":
                lcalDatas.clear();
                List<GeoGeomorphySvyPointDbEntity> geoGeomorphySvyPointDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(GeoGeomorphySvyPointDbEntity.class);
                refreshLayout1.finishRefresh();
                if (geoGeomorphySvyPointDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geoGeomorphySvyPointDbEntities.size(); i++) {
                    if (projectId.equals(geoGeomorphySvyPointDbEntities.get(i).getProjectId())
                            && taskId.equals(geoGeomorphySvyPointDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(geoGeomorphySvyPointDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(geoGeomorphySvyPointDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geoGeomorphySvyPointDbEntities.get(i).getId());
                        localBean.set_id(geoGeomorphySvyPointDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "5":
                lcalDatas.clear();
                List<GeologicalSvyLineDbEntitiy> geologicalSvyLineDbEntitiys
                        = BaseApplication.getInstance().getDaoSession().loadAll(GeologicalSvyLineDbEntitiy.class);
                refreshLayout1.finishRefresh();
                if (geologicalSvyLineDbEntitiys.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geologicalSvyLineDbEntitiys.size(); i++) {
                    if (projectId.equals(geologicalSvyLineDbEntitiys.get(i).getProjectId())
                            && taskId.equals(geologicalSvyLineDbEntitiys.get(i).getTaskId())
                            && !TextUtils.isEmpty(geologicalSvyLineDbEntitiys.get(i).getProjectId())
                            && !TextUtils.isEmpty(geologicalSvyLineDbEntitiys.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geologicalSvyLineDbEntitiys.get(i).getId());
                        localBean.set_id(geologicalSvyLineDbEntitiys.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "6":
                lcalDatas.clear();
                List<GeologicalSvyPointDbEntity> geologicalSvyPointDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(GeologicalSvyPointDbEntity.class);
                refreshLayout1.finishRefresh();
                if (geologicalSvyPointDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geologicalSvyPointDbEntities.size(); i++) {
                    if (projectId.equals(geologicalSvyPointDbEntities.get(i).getProjectId())
                            && taskId.equals(geologicalSvyPointDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(geologicalSvyPointDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(geologicalSvyPointDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geologicalSvyPointDbEntities.get(i).getId());
                        localBean.set_id(geologicalSvyPointDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "7":
                lcalDatas.clear();
                List<StratigraphySvyPointDbEntity> stratigraphySvyPointDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(StratigraphySvyPointDbEntity.class);
                refreshLayout1.finishRefresh();
                if (stratigraphySvyPointDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < stratigraphySvyPointDbEntities.size(); i++) {
                    if (projectId.equals(stratigraphySvyPointDbEntities.get(i).getProjectId())
                            && taskId.equals(stratigraphySvyPointDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(stratigraphySvyPointDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(stratigraphySvyPointDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(stratigraphySvyPointDbEntities.get(i).getId());
                        localBean.set_id(stratigraphySvyPointDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "8":
                lcalDatas.clear();
                List<TanCaodianDbEntity> tanCaodianDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(TanCaodianDbEntity.class);
                refreshLayout1.finishRefresh();
                if (tanCaodianDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < tanCaodianDbEntities.size(); i++) {
                    if (projectId.equals(tanCaodianDbEntities.get(i).getProjectId())
                            && taskId.equals(tanCaodianDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(tanCaodianDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(tanCaodianDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(tanCaodianDbEntities.get(i).getId());
                        localBean.set_id(tanCaodianDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "9":
                lcalDatas.clear();
                List<GeomorphySvyLineDbEntity> geomorphySvyLineDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(GeomorphySvyLineDbEntity.class);
                refreshLayout1.finishRefresh();
                if (geomorphySvyLineDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geomorphySvyLineDbEntities.size(); i++) {
                    if (projectId.equals(geomorphySvyLineDbEntities.get(i).getProjectId())
                            && taskId.equals(geomorphySvyLineDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(geomorphySvyLineDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(geomorphySvyLineDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geomorphySvyLineDbEntities.get(i).getId());
                        localBean.set_id(geomorphySvyLineDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "10":
                lcalDatas.clear();
                List<GeomorphySvyPointDbEntity> geomorphySvyPointDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(GeomorphySvyPointDbEntity.class);
                refreshLayout1.finishRefresh();
                if (geomorphySvyPointDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geomorphySvyPointDbEntities.size(); i++) {
                    if (projectId.equals(geomorphySvyPointDbEntities.get(i).getProjectId())
                            && taskId.equals(geomorphySvyPointDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(geomorphySvyPointDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(geomorphySvyPointDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geomorphySvyPointDbEntities.get(i).getId());
                        localBean.set_id(geomorphySvyPointDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "11":
                lcalDatas.clear();
                List<GeomorphySvyRegionDbEntity> geomorphySvyRegionDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(GeomorphySvyRegionDbEntity.class);
                refreshLayout1.finishRefresh();
                if (geomorphySvyRegionDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geomorphySvyRegionDbEntities.size(); i++) {
                    if (projectId.equals(geomorphySvyRegionDbEntities.get(i).getProjectId())
                            && taskId.equals(geomorphySvyRegionDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(geomorphySvyRegionDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(geomorphySvyRegionDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geomorphySvyRegionDbEntities.get(i).getId());
                        localBean.set_id(geomorphySvyRegionDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "12":
                lcalDatas.clear();
                List<GeomorphySvyReProfDbEntity> geomorphySvyReProfDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(GeomorphySvyReProfDbEntity.class);
                refreshLayout1.finishRefresh();
                if (geomorphySvyReProfDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geomorphySvyReProfDbEntities.size(); i++) {
                    if (projectId.equals(geomorphySvyReProfDbEntities.get(i).getProjectId())
                            && taskId.equals(geomorphySvyReProfDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(geomorphySvyReProfDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(geomorphySvyReProfDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geomorphySvyReProfDbEntities.get(i).getId());
                        localBean.set_id(geomorphySvyReProfDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "13":
                lcalDatas.clear();
                List<GeomorphySvySamplePointDbEntity> geomorphySvySamplePointDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(GeomorphySvySamplePointDbEntity.class);
                refreshLayout1.finishRefresh();
                if (geomorphySvySamplePointDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geomorphySvySamplePointDbEntities.size(); i++) {
                    if (projectId.equals(geomorphySvySamplePointDbEntities.get(i).getProjectId())
                            && taskId.equals(geomorphySvySamplePointDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(geomorphySvySamplePointDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(geomorphySvySamplePointDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geomorphySvySamplePointDbEntities.get(i).getId());
                        localBean.set_id(geomorphySvySamplePointDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "14":
                lcalDatas.clear();
                List<GeomorStationDbEntity> geomorStationDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(GeomorStationDbEntity.class);
                refreshLayout1.finishRefresh();
                if (geomorStationDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geomorStationDbEntities.size(); i++) {
                    if (projectId.equals(geomorStationDbEntities.get(i).getProjectId())
                            && taskId.equals(geomorStationDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(geomorStationDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(geomorStationDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geomorStationDbEntities.get(i).getId());
                        localBean.set_id(geomorStationDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "15":
                lcalDatas.clear();
                List<DrillHoleDbEntity> drillHoleDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(DrillHoleDbEntity.class);
                refreshLayout1.finishRefresh();
                if (drillHoleDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < drillHoleDbEntities.size(); i++) {
                    if (projectId.equals(drillHoleDbEntities.get(i).getProjectId())
                            && taskId.equals(drillHoleDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(drillHoleDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(drillHoleDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(drillHoleDbEntities.get(i).getId());
                        localBean.set_id(drillHoleDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "16":
                lcalDatas.clear();
                List<SamplePointDbEntity> samplePointDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(SamplePointDbEntity.class);
                refreshLayout1.finishRefresh();
                if (samplePointDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < samplePointDbEntities.size(); i++) {
                    if (projectId.equals(samplePointDbEntities.get(i).getProjectId())
                            && taskId.equals(samplePointDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(samplePointDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(samplePointDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(samplePointDbEntities.get(i).getId());
                        localBean.set_id(samplePointDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "17":
                lcalDatas.clear();
                List<GeophySvyLineDbEntity> geophySvyLineDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(GeophySvyLineDbEntity.class);
                refreshLayout1.finishRefresh();
                if (geophySvyLineDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geophySvyLineDbEntities.size(); i++) {
                    if (projectId.equals(geophySvyLineDbEntities.get(i).getProjectId())
                            && taskId.equals(geophySvyLineDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(geophySvyLineDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(geophySvyLineDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geophySvyLineDbEntities.get(i).getId());
                        localBean.set_id(geophySvyLineDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "18":
                lcalDatas.clear();
                List<GeophySvyPointDbEntity> geophySvyPointDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(GeophySvyPointDbEntity.class);
                refreshLayout1.finishRefresh();
                if (geophySvyPointDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geophySvyPointDbEntities.size(); i++) {
                    if (projectId.equals(geophySvyPointDbEntities.get(i).getProjectId())
                            && taskId.equals(geophySvyPointDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(geophySvyPointDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(geophySvyPointDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geophySvyPointDbEntities.get(i).getId());
                        localBean.set_id(geophySvyPointDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "19":
                lcalDatas.clear();
                List<GeochemicalSvyLineDbEntity> geochemicalSvyLineDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(GeochemicalSvyLineDbEntity.class);
                refreshLayout1.finishRefresh();
                if (geochemicalSvyLineDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geochemicalSvyLineDbEntities.size(); i++) {
                    if (projectId.equals(geochemicalSvyLineDbEntities.get(i).getProjectId())
                            && taskId.equals(geochemicalSvyLineDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(geochemicalSvyLineDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(geochemicalSvyLineDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geochemicalSvyLineDbEntities.get(i).getId());
                        localBean.set_id(geochemicalSvyLineDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "20":
                lcalDatas.clear();
                List<GeochemicalSvyPointDbEntity> geochemicalSvyPointDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(GeochemicalSvyPointDbEntity.class);
                refreshLayout1.finishRefresh();
                if (geochemicalSvyPointDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < geochemicalSvyPointDbEntities.size(); i++) {
                    if (projectId.equals(geochemicalSvyPointDbEntities.get(i).getProjectId())
                            && taskId.equals(geochemicalSvyPointDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(geochemicalSvyPointDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(geochemicalSvyPointDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(geochemicalSvyPointDbEntities.get(i).getId());
                        localBean.set_id(geochemicalSvyPointDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "21":
                lcalDatas.clear();
                List<CreaterDbEntity> createrDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(CreaterDbEntity.class);
                refreshLayout1.finishRefresh();
                if (createrDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < createrDbEntities.size(); i++) {
                    if (projectId.equals(createrDbEntities.get(i).getProjectId())
                            && taskId.equals(createrDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(createrDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(createrDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(createrDbEntities.get(i).getId());
                        localBean.set_id(createrDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "22":
                lcalDatas.clear();
                List<LavaDbEntity> lavaDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(LavaDbEntity.class);
                refreshLayout1.finishRefresh();
                if (lavaDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < lavaDbEntities.size(); i++) {
                    if (projectId.equals(lavaDbEntities.get(i).getProjectId())
                            && taskId.equals(lavaDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(lavaDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(lavaDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(lavaDbEntities.get(i).getId());
                        localBean.set_id(lavaDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            case "23":
                lcalDatas.clear();
                List<VolcanicSamplePointDbEntity> volcanicSamplePointDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(VolcanicSamplePointDbEntity.class);
                refreshLayout1.finishRefresh();
                if (volcanicSamplePointDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < volcanicSamplePointDbEntities.size(); i++) {
                    if (projectId.equals(volcanicSamplePointDbEntities.get(i).getProjectId())
                            && taskId.equals(volcanicSamplePointDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(volcanicSamplePointDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(volcanicSamplePointDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(volcanicSamplePointDbEntities.get(i).getId());
                        localBean.set_id(volcanicSamplePointDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
            default:
                lcalDatas.clear();
                List<VolcanicSvyPointDbEntity> volcanicSvyPointDbEntities
                        = BaseApplication.getInstance().getDaoSession().loadAll(VolcanicSvyPointDbEntity.class);
                refreshLayout1.finishRefresh();
                if (volcanicSvyPointDbEntities.size() == 0) {
                    localAdapter.notifyDataSetChanged();
                    return;
                }
                for (int i = 0; i < volcanicSvyPointDbEntities.size(); i++) {
                    if (projectId.equals(volcanicSvyPointDbEntities.get(i).getProjectId())
                            && taskId.equals(volcanicSvyPointDbEntities.get(i).getTaskId())
                            && !TextUtils.isEmpty(volcanicSvyPointDbEntities.get(i).getProjectId())
                            && !TextUtils.isEmpty(volcanicSvyPointDbEntities.get(i).getTaskId())
                    ) {
                        LocalBean localBean = new LocalBean();
                        localBean.setTitle(volcanicSvyPointDbEntities.get(i).getId());
                        localBean.set_id(volcanicSvyPointDbEntities.get(i).get_id());
                        lcalDatas.add(localBean);
                    }
                }
                localAdapter.notifyDataSetChanged();
                break;
        }
    }

    private void deletePosition(int position) {
        long id = lcalDatas.get(position).get_id();
        switch (selectTableId) {
            case "1":
                List<GeologicalSvyPlanningLineDbEntity> students =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeologicalSvyPlanningLineDbEntity.class);
                for (GeologicalSvyPlanningLineDbEntity geologicalSvyPlanningLineDbEntity : students) {
                    if (id == geologicalSvyPlanningLineDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geologicalSvyPlanningLineDbEntity);
                    }
                }
                break;
            case "2":
                List<GeologicalSvyPlanningPtDbEntity> geologicalSvyPlanningPtDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeologicalSvyPlanningPtDbEntity.class);
                for (GeologicalSvyPlanningPtDbEntity geologicalSvyPlanningPtDbEntity : geologicalSvyPlanningPtDbEntities) {
                    if (id == geologicalSvyPlanningPtDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geologicalSvyPlanningPtDbEntity);
                    }
                }
                break;
            case "3":
                List<FaultSvyPointDbEntity> faultSvyPointDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(FaultSvyPointDbEntity.class);
                for (FaultSvyPointDbEntity faultSvyPointDbEntity : faultSvyPointDbEntities) {
                    if (id == faultSvyPointDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(faultSvyPointDbEntity);
                    }
                }
                break;
            case "4":
                List<GeoGeomorphySvyPointDbEntity> geoGeomorphySvyPointDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeoGeomorphySvyPointDbEntity.class);
                for (GeoGeomorphySvyPointDbEntity geoGeomorphySvyPointDbEntity : geoGeomorphySvyPointDbEntities) {
                    if (id == geoGeomorphySvyPointDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geoGeomorphySvyPointDbEntity);
                    }
                }
                break;
            case "5":
                List<GeologicalSvyLineDbEntitiy> geologicalSvyLineDbEntitiys =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeologicalSvyLineDbEntitiy.class);
                for (GeologicalSvyLineDbEntitiy geologicalSvyLineDbEntitiy : geologicalSvyLineDbEntitiys) {
                    if (id == geologicalSvyLineDbEntitiy.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geologicalSvyLineDbEntitiy);
                    }
                }
                break;
            case "6":
                List<GeologicalSvyPointDbEntity> geologicalSvyPointDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeologicalSvyPointDbEntity.class);
                for (GeologicalSvyPointDbEntity geologicalSvyLineDbEntitiy : geologicalSvyPointDbEntities) {
                    if (id == geologicalSvyLineDbEntitiy.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geologicalSvyLineDbEntitiy);
                    }
                }
                break;
            case "7":
                List<StratigraphySvyPointDbEntity> stratigraphySvyPointDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(StratigraphySvyPointDbEntity.class);
                for (StratigraphySvyPointDbEntity stratigraphySvyPointDbEntity : stratigraphySvyPointDbEntities) {
                    if (id == stratigraphySvyPointDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(stratigraphySvyPointDbEntity);
                    }
                }
                break;
            case "8":
                List<TanCaodianDbEntity> tanCaodianDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(TanCaodianDbEntity.class);
                for (TanCaodianDbEntity tanCaodianDbEntity : tanCaodianDbEntities) {
                    if (id == tanCaodianDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(tanCaodianDbEntity);
                    }
                }
                break;
            case "9":
                List<GeomorphySvyLineDbEntity> geomorphySvyLineDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeomorphySvyLineDbEntity.class);
                for (GeomorphySvyLineDbEntity geomorphySvyLineDbEntity : geomorphySvyLineDbEntities) {
                    if (id == geomorphySvyLineDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geomorphySvyLineDbEntity);
                    }
                }
                break;
            case "10":
                List<GeomorphySvyPointDbEntity> geomorphySvyPointDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeomorphySvyPointDbEntity.class);
                for (GeomorphySvyPointDbEntity geomorphySvyPointDbEntity : geomorphySvyPointDbEntities) {
                    if (id == geomorphySvyPointDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geomorphySvyPointDbEntity);
                    }
                }
                break;
            case "11":
                List<GeomorphySvyRegionDbEntity> geomorphySvyRegionDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeomorphySvyRegionDbEntity.class);
                for (GeomorphySvyRegionDbEntity geomorphySvyRegionDbEntity : geomorphySvyRegionDbEntities) {
                    if (id == geomorphySvyRegionDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geomorphySvyRegionDbEntity);
                    }
                }
                break;
            case "12":
                List<GeomorphySvyReProfDbEntity> geomorphySvyReProfDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeomorphySvyReProfDbEntity.class);
                for (GeomorphySvyReProfDbEntity geomorphySvyReProfDbEntity : geomorphySvyReProfDbEntities) {
                    if (id == geomorphySvyReProfDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geomorphySvyReProfDbEntity);
                    }
                }
                break;
            case "13":
                List<GeomorphySvySamplePointDbEntity> geomorphySvySamplePointDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeomorphySvySamplePointDbEntity.class);
                for (GeomorphySvySamplePointDbEntity geomorphySvySamplePointDbEntity : geomorphySvySamplePointDbEntities) {
                    if (id == geomorphySvySamplePointDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geomorphySvySamplePointDbEntity);
                    }
                }
                break;
            case "14":
                List<GeomorStationDbEntity> geomorStationDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeomorStationDbEntity.class);
                for (GeomorStationDbEntity geomorStationDbEntity : geomorStationDbEntities) {
                    if (id == geomorStationDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geomorStationDbEntity);
                    }
                }
                break;
            case "15":
                List<DrillHoleDbEntity> drillHoleDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(DrillHoleDbEntity.class);
                for (DrillHoleDbEntity geomorStationDbEntity : drillHoleDbEntities) {
                    if (id == geomorStationDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geomorStationDbEntity);
                    }
                }
                break;
            case "16":
                List<SamplePointDbEntity> samplePointDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(SamplePointDbEntity.class);
                for (SamplePointDbEntity samplePointDbEntity : samplePointDbEntities) {
                    if (id == samplePointDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(samplePointDbEntity);
                    }
                }
                break;
            case "17":
                List<GeophySvyLineDbEntity> geophySvyLineDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeophySvyLineDbEntity.class);
                for (GeophySvyLineDbEntity geophySvyLineDbEntity : geophySvyLineDbEntities) {
                    if (id == geophySvyLineDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geophySvyLineDbEntity);
                    }
                }
                break;
            case "18":
                List<GeophySvyPointDbEntity> geophySvyPointDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeophySvyPointDbEntity.class);
                for (GeophySvyPointDbEntity geophySvyPointDbEntity : geophySvyPointDbEntities) {
                    if (id == geophySvyPointDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geophySvyPointDbEntity);
                    }
                }
                break;
            case "19":
                List<GeochemicalSvyLineDbEntity> geochemicalSvyLineDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeochemicalSvyLineDbEntity.class);
                for (GeochemicalSvyLineDbEntity geochemicalSvyLineDbEntity : geochemicalSvyLineDbEntities) {
                    if (id == geochemicalSvyLineDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geochemicalSvyLineDbEntity);
                    }
                }
                break;
            case "20":
                List<GeochemicalSvyPointDbEntity> geochemicalSvyPointDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(GeochemicalSvyPointDbEntity.class);
                for (GeochemicalSvyPointDbEntity geochemicalSvyPointDbEntity : geochemicalSvyPointDbEntities) {
                    if (id == geochemicalSvyPointDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(geochemicalSvyPointDbEntity);
                    }
                }
                break;
            case "21":
                List<CreaterDbEntity> createrDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(CreaterDbEntity.class);
                for (CreaterDbEntity createrDbEntity : createrDbEntities) {
                    if (id == createrDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(createrDbEntity);
                    }
                }
                break;
            case "22":
                List<LavaDbEntity> lavaDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(LavaDbEntity.class);
                for (LavaDbEntity lavaDbEntity : lavaDbEntities) {
                    if (id == lavaDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(lavaDbEntity);
                    }
                }
                break;
            case "23":
                List<VolcanicSamplePointDbEntity> volcanicSamplePointDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(VolcanicSamplePointDbEntity.class);
                for (VolcanicSamplePointDbEntity volcanicSamplePointDbEntity : volcanicSamplePointDbEntities) {
                    if (id == volcanicSamplePointDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(volcanicSamplePointDbEntity);
                    }
                }
                break;
            default:
                List<VolcanicSvyPointDbEntity> volcanicSvyPointDbEntities =
                        BaseApplication.getInstance().getDaoSession().loadAll(VolcanicSvyPointDbEntity.class);
                for (VolcanicSvyPointDbEntity volcanicSvyPointDbEntity : volcanicSvyPointDbEntities) {
                    if (id == volcanicSvyPointDbEntity.get_id()) {
                        BaseApplication.getInstance().getDaoSession().delete(volcanicSvyPointDbEntity);
                    }
                }
                break;
        }
    }

    private void http() {
        String url = Api.FIND_APP_FORM_DATA + "?curPage="
                + pageNum + "&projectId=" + projectId + "&pageSize=10"
                + "&taskId=" + taskId + "&userId=" + SPUtil.get("userId", "")
                + "&type=" + selectTableId;
        MyHttpClient
                .newBuilder()
                .get()
                .url(url)
                .build()
                .enqueue(new BaseCallBack<SeeTableBean>() {
                    @Override
                    public void onSuccess(SeeTableBean bean) {
                        super.onSuccess(bean);
                        refreshLayout.finishLoadmore();
                        refreshLayout.finishRefresh();
                        if (bean != null && bean.getCode() == 200) {
                            datas.clear();
                            List<TableBean> result = bean.getData();
                            datas.addAll(result);
                            mAdapter.notifyDataSetChanged();
                        } else {
                            CustomToast.showToast(SeeTableListActivity.this, "获取失败");
                        }
                    }

                    @Override
                    public void onFailure(Call call, IOException e) {
                        super.onFailure(call, e);
                        SeeTableListActivity.this.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                CustomToast.showToast(SeeTableListActivity.this, "网络异常");
                            }
                        });
                        refreshLayout.finishLoadmore();
                        refreshLayout.finishRefresh();
                    }
                });
    }
}
